#include "../include/FireworkLib.h"

#include "../include/FireworkCircles.h"
#include "../include/FireworkCone.h"
#include "../include/FireworkBall.h"
#include "../include/FireworkRosebush.h"
#include "../include/FireworkLines.h"
#include "../include/FireworkCircle.h"
#include "../include/FireworkCircleAndInBall.h"
#include "../include/FireworkLinesAndInBall.h"
#include "../include/FireworkLittleLines.h"

std::shared_ptr<FireworkBase> FireworkLib::getRandomFirework() {
	std::random_device rd;  // 将用于获得随机数引擎的种子
	auto gen = std::mt19937_64(rd()); // 以 rd() 播种的标准 mersenne_twister_engine
	std::shared_ptr<FireworkBase> res;
	uint8_t fireworkCalss = 9;
	std::uniform_int_distribution<> classDis(0, 50);
	std::uniform_real_distribution<float> posDis(-20, 50);
	Vector3 pos{posDis(gen), posDis(gen), 0};
	std::uniform_real_distribution<float> speedDis(30, 50);
	float speed = speedDis(gen);
	uint8_t fireworkCalssSwtich = div(classDis(gen), fireworkCalss).rem;
	switch (fireworkCalssSwtich) {
		case 0:
			res = std::make_shared<FireworkBall>(pos, speed);
			break;
		case 1:
			res = std::make_shared<FireworkCircles>(pos, speed);
			break;
		case 2:
			res = std::make_shared<FireworkRosebush>(pos, speed);
			break;
		case 3:
			res = std::make_shared<FireworkLines>(pos, speed);
			break;
		case 4:
			res = std::make_shared<FireworkCircle>(pos, speed);
			break;
		case 5:
			res = std::make_shared<FireworkCircleAndInBall>(pos, speed);
			break;
		case 6:
			res = std::make_shared<FireworkLinesAndInBall>(pos, speed);
			break;
		case 7:
			res = std::make_shared<FireworkLittleLines>(pos, speed);
			break;
		default:
			res = std::make_shared<FireworkCone>(pos, speed);
			break;
	}
	//加载音效
	Sound raiseBgm = LoadSound("./res/raise.wav");
	Sound bombBgm = LoadSound("./res/bomb.wav");
	res->setBombBgm(std::make_shared<Sound>(bombBgm));
	res->setRaiseBgm(std::make_shared<Sound>(raiseBgm));
	res->activate();
	return res;
}
